<?php 
namespace Common\Model;
use Common\Model\BaseModel;
//使用D()方法需要自己写一个moiba
class AdminModel extends BaseModel{
	//无表前缀的管理员表
	protected $table;
	//有表前缀的管理员表
	protected $admintable;
	//表前缀
	protected $pre;
	 /**构造函数初始化数据
     * @param string $adminTable
     * @param string $prefix
     */
	public function __construct($admintable,$pre = ''){
		parent::__construct();
		$this->pre = !empty($pre) ? $pre : C('') ; 
		$this->table = $admintable;
		$this->admintable = $this->pre.$admintable;

	}
	/**获取指定用户的信息
     * @param $name
     * @return bool|mixed
     */
	public function adminInfo($name){
		$result = $this->query('select id,name,pwd,realname from '.$this->$admintable .'where status = 1 and name ="'.$name.'"'); //执行查询

		if(empty($result)){
			return $loginarr = ['status' => 0,'mess' => '用户不存在','data' => ''];
		}
		return $loginarr = ['status' => 1,'mess' => '登录成功！','data' => $result];

	}

	public function updateLogin($id){
		$result = $this->execute('update dx_admin set loginnum = loginnum + 1 where id='.$id);//执行更新和写入语句
		if(empty($result)){
			return false;
		}
		return true;
	}




}

